default:build

build:
	nvcc --cudart shared -keep  -o hello hello.cu
	nvcc --cudart shared -keep  -o sum_matrix sum_matrix.cu

ptx:
	nvcc -ptx --cudart shared -o hello hello.cu
	nvcc -ptx --cudart shared -o sum_matrix sum_matrix.cu

run: build
	./hello

ldd:
	ldd hello
	ldd sum_matrix

dryrun:
	nvcc -O2 -c hello.cu -keep -arch sm_50 --dryrun
	nvcc -O2 -c sum_matrix.cu -keep -arch sm_50 --dryrun

dot:
	nvdisasm -cfg hello.sm_52.cubin | dot -ohello.png -Tpng
	nvdisasm -cfg sum_matrix.sm_52.cubin | dot -osum_matrix.png -Tpng

sass:
	nvdisasm hello.sm_52.cubin > hello.sm_52.sass
	nvdisasm sum_matrix.sm_52.cubin > sum_matrix.sm_52.sass
	nvdisasm -c -plr hello.sm_52.cubin > hello.sm_52.plr.sass
	nvdisasm -c -plr sum_matrix.sm_52.cubin > sum_matrix.sm_52.plr.sass

cuobjdump:
	cuobjdump -xelf all hello
	cuobjdump -xelf all sum_matrix

clean:
	-rm -rf hello_dlink.*
	-rm -rf hello_dlink.* hello gpgpusim_power_report*.log _app_cuda_version_* _cuobjdump_list_ptx_* hello.1.* gpgpu_inst_stats.txt checkpoint_files gpgpusim_visualizer*.log.gz hello.fatbin hello.fatbin.c hello.cpp1.ii hello.cpp4.ii hello.cudafe1.c hello.cudafe1.cpp hello.cudafe1.gpu hello.cudafe1.stub.c hello.module_id hello.ptx hello.o hello.sm_52.cubin hello.sm_52.plr.sass hello.png
	-rm -rf sum_matrix_dlink.*
	-rm -rf sum_matrix gpgpusim_power_report*.log _app_cuda_version_* _cuobjdump_list_ptx_* sum_matrix.1.* gpgpu_inst_stats.txt checkpoint_files gpgpusim_visualizer*.log.gz sum_matrix.fatbin sum_matrix.fatbin.c sum_matrix.cpp1.ii sum_matrix.cpp4.ii sum_matrix.cudafe1.c sum_matrix.cudafe1.cpp sum_matrix.cudafe1.gpu sum_matrix.cudafe1.stub.c sum_matrix.module_id sum_matrix.ptx sum_matrix.o sum_matrix.sm_52.cubin
	-rm -rf *.sass *.cubin sum_matrix.png
